<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<c:set value="recruit" var="moduleName" scope="request" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>在线申请 - 背景状况</title>
	</head>
	<body>
		<html:form action="/site/user/applyBg.do" styleId="mainForm" method="POST" >
			<input type="hidden" name="method" class="method" value="save" />
			<html:hidden property="id" />
			<html:hidden property="applyBaseId" />
			<input type="hidden" name="direction" id="direction" value="" />
			<div class="site-title">
				五、 申请者背景状况

			</div>
			<br />
			<div class="div-content">
			<table class="table-layout">
				<tr class="tr-even">
					<td>
						如果申请公司或相关公司（母公司、分/子公司及关联公司）具备汽车行业从业经历，请提供以下信息：
					</td>
				</tr>
				<tr class="tr-odd">
					<td>
						截至上年度（
						<html:text property="shopLastYear1" styleClass="Wdate" style="width:60px" onclick="WdatePicker({dateFmt:'yyyy'})" />年

						）年底，所拥有的小轿车销售/服务店共
						<html:text property="shopAmount" style="width:60px;" styleId="shopAmount" onkeyup="keyUpOnlyNum(this)"/>
						家，其中4S店共
						<html:text property="shop4sAmount" style="width:60px;" styleId="shop4sAmount" onkeyup="keyUpOnlyNum(this);changeShopInputState();"/>
						家；
					</td>
				</tr>
				<tr class="tr-even">
					<td>
						注：本评审模型中所指的小轿车销售/服务店均指上一自然年度内，为投资方所控制的，可以纳入投资方合并财务报表的，独立法人的小型乘用车(除微面)销售/服务店。尚未开始正式运营、已关停并转或即将关停并转的小轿车销售/服务店不计算在内。小轿车销售/服务店包含品牌4S店、综合品牌销售店及综合品牌服务站/修理厂。

					</td>
				</tr>
				<tr class="tr-odd">
					<td>
						上年度（
						<html:text property="shopLastYear2" styleClass="Wdate" style="width:60px"  onclick="WdatePicker({dateFmt:'yyyy'})" />年

						）集团及业绩表现排名前三的汽车销售/服务店的经营状况
					</td>
				</tr>
			</table>
			<table class="table-layout">
				<tr class="tr-even">
					<td width="150">
						项目
					</td>
					<td>
						集团总体
					</td>
					<td>
						<p>
							排名第一
							<br />
							店名：

							<html:text property="shop1" />
							<br />
							品牌：

							<html:text property="shopBrand1" />
						</p>
					</td>
					<td>
						<p>
							排名第二
							<br>
							店名：

							<html:text property="shop2" />
							<br>

							品牌：

							<html:text property="shopBrand2" />
						</p>
					</td>
					<td>
						<p>
							排名第三
							<br>
							店名：

							<html:text property="shop3" />
							<br>
							品牌：

							<html:text property="shopBrand3" />
						</p>
					</td>
				</tr>
				<tr class="tr-odd">
					<td>
						开业时间（年月）

					</td>
					<td>
						——

					</td>
					<td>
						<html:text property="shopStart1" styleClass="Wdate"  onclick="WdatePicker({dateFmt:'yyyy年MM月'})" />
					</td>
					<td>
						<html:text property="shopStart2" styleClass="Wdate"  onclick="WdatePicker({dateFmt:'yyyy年MM月'})" />
					</td>
					<td>
						<html:text property="shopStart3" styleClass="Wdate"  onclick="WdatePicker({dateFmt:'yyyy年MM月'})" />
					</td>
				</tr>
				<tr class="tr-even">
					<td>
						所在城市

					</td>
					<td>
						——

					</td>
					<td>
						<html:text property="shopCity1" />
					</td>
					<td>
						<html:text property="shopCity2" />
					</td>
					<td>
						<html:text property="shopCity3" />
					</td>
				</tr>
				<tr class="tr-odd">
					<td>
						销量(台)
					</td>
					<td>
						<html:text property="totalSalesVolume" styleId="totalSalesVolume" onkeyup="keyUpOnlyNum(this)"/>
					</td>
					<td>
						<html:text property="shopSalesVolume1" styleId="shopSalesVolume1" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalSalesVolume','shopSalesVolume')"/>
					</td>
					<td>
						<html:text property="shopSalesVolume2" styleId="shopSalesVolume2" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalSalesVolume','shopSalesVolume')"/>
					</td>
					<td>
						<html:text property="shopSalesVolume3" styleId="shopSalesVolume3" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalSalesVolume','shopSalesVolume')"/>
					</td>
				</tr>
				<tr class="tr-even">
					<td>
						销售额(万元)
					</td>
					<td>
						<html:text property="totalSale" styleId="totalSale" onkeyup="keyUpOnlyNum(this)"/>
					</td>
					<td>
						<html:text property="shopSale1" styleId="shopSale1" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalSale','shopSale')"/>
					</td>
					<td>
						<html:text property="shopSale2" styleId="shopSale2" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalSale','shopSale')"/>
					</td>
					<td>
						<html:text property="shopSale3" styleId="shopSale3" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalSale','shopSale')"/>
					</td>
				</tr>
				<tr class="tr-odd">
					<td>
						维修台次(台)
					</td>
					<td>
						<html:text property="totalServicesVolume" styleId="totalServicesVolume" onkeyup="keyUpOnlyNum(this)"/>
					</td>
					<td>
						<html:text property="shopServicesVolume1" styleId="shopServicesVolume1" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalServicesVolume','shopServicesVolume')"/>
					</td>
					<td>
						<html:text property="shopServicesVolume2" styleId="shopServicesVolume2" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalServicesVolume','shopServicesVolume')"/>
					</td>
					<td>
						<html:text property="shopServicesVolume3" styleId="shopServicesVolume3" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalServicesVolume','shopServicesVolume')"/>
					</td>
				</tr>
				<tr class="tr-even">
					<td>
						维修产值(万元)
					</td>
					<td>
						<html:text property="totalService"  styleId="totalService" onkeyup="keyUpOnlyNum(this)"/>
					</td>
					<td>
						<html:text property="shopService1"  styleId="shopService1" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalService','shopService')"/>
					</td>
					<td>
						<html:text property="shopService2"  styleId="shopService2" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalService','shopService')"/>
					</td>
					<td>
						<html:text property="shopService3"  styleId="shopService3" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalService','shopService')"/>
					</td>
				</tr>
				<tr class="tr-odd">
					<td>
						税后利润(万元)
					</td>
					<td>
						<html:text property="totalProfit" styleId="totalProfit" onkeyup="keyUpOnlyNum(this)"/>
					</td>
					<td>
						<html:text property="shopProfit1" styleId="shopProfit1" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalProfit','shopProfit')"/>
					</td>
					<td>
						<html:text property="shopProfit2" styleId="shopProfit2" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalProfit','shopProfit')"/>
					</td>
					<td>
						<html:text property="shopProfit3" styleId="shopProfit3" onkeyup="keyUpOnlyNum(this);calTotalInfo('totalProfit','shopProfit')"/>
					</td>
				</tr>
			</table>
			<table class="table-layout">
				<tr class="tr-even">
					<td>
						经营的品牌有：

						<html:text property="brands" style="width:500px;" />
					</td>
				</tr>
			</table>
			<br />
			<div class="center-opertion">
				<html:submit onclick="formSubmit();">保存</html:submit>
				<input type="button" value="上一步" onclick="toStep(-1)" />
				<input type="button" value="下一步" onclick="toStep(1)" />
				<html:cancel>取消</html:cancel>
			</div>
			</div>
		</html:form>
		<script type="text/javascript">
	function toStep(num){
		if(num > 0)
			_g("direction").value="next";
		else if(num < 0)
			_g("direction").value="last";
		formSubmit();
	}
	function changeShopInputState(){		
		var num=_g('shop4sAmount').value;
		var totalShopInputName=['totalSalesVolume','totalSale','totalServicesVolume','totalService','totalProfit'];
		var checkedForm=_g("mainForm");		
		/*if(num>3){
			for(var i=0;i<totalShopInputName.length;i++){
				checkedForm[totalShopInputName[i]].readOnly="";						
			}
		}else{
			for(var i=0;i<totalShopInputName.length;i++){
				checkedForm[totalShopInputName[i]].readOnly="readonly";				
			}
		}*/
	}
	function checkTotalInfo(){	
		var totalShopInputName=['totalSalesVolume','totalSale','totalServicesVolume','totalService','totalProfit'];
		var formElementPrefix=['shopSalesVolume','shopSale','shopServicesVolume','shopService','shopProfit'];
		var titleInfo=['销量','销售额','维修台次','维修产值','税后利润'];
		var num=_g('shop4sAmount').value;
		var checkedForm=_g("mainForm");		
		var i=0;
		if(num>=3){
			i=3;
		}else if(num!=''){
			i=num;
		}
		var flag=true;
		for (var m=0;m<totalShopInputName.length;m++){
			var totalElementName=totalShopInputName[m];
			var totalinfo=checkedForm[totalElementName].value*1;
			var calculateTotalInfo=0;
			for(var n=0;n<i;n++){				
				var elementName=formElementPrefix[m]+(n+1);
				calculateTotalInfo+=checkedForm[elementName].value*1;				
			}
			if(totalinfo<calculateTotalInfo){
				alert("各分店 "+titleInfo[m]+" 总和必须小于集团的总 "+titleInfo[m]+"!");
				checkedForm[totalElementName].focus();
				flag=false;
				break;
			}
		}
		return flag;
	}
	
	function calTotalInfo(totalid,prefix){
	/*	var totalobj=_g(totalid);
		var num=_g('shop4sAmount').value;
		if(num!=''&& num<4){
			var prefixValue1=_g(prefix+"1").value;
			var prefixValue2=_g(prefix+"2").value;
			var prefixValue3=_g(prefix+"3").value;
			totalobj.value=prefixValue1*1+prefixValue2*1+prefixValue3*1;	
		}*/
	}
	function keyUpOnlyNum(obj){		
		obj.value=obj.value.replace(/\D/g,'');
	}
	
	function formSubmit(){
		if(checkForm())
			_g("mainForm").submit();
	}
	
	function checkForm(){
		var checkedForm=_g("mainForm");		
		var currentYear='<%=request.getAttribute("currentYear")%>';
		var formElementPrefix=['shop','shopBrand','shopStart','shopCity','shopSalesVolume','shopSale','shopServicesVolume','shopService','shopProfit'];
		var titleInfo=['店名','品牌','开业时间','所在城市','销量','销售额','维修台次','维修产值','税后利润'];
		var num=_g('shop4sAmount').value;
		var i=0
		var checkYearFlag=true;
		for (var n=0;n<2;n++){
			var tempYear=checkedForm['shopLastYear'+(n+1)];
			if(tempYear.value!=''&&tempYear.value>currentYear){
				alert('上年度不能大于当前年份！');
				checkYearFlag=false;
				tempYear.focus();
			}
			if(!checkYearFlag)
				break;
		}
		if(!checkYearFlag)
			return checkYearFlag;
		var flag=true;		
		if(num>=3){
			i=3;
		}else if(num!=''){
			i=num;
		}
		for(var n=0;n<i;n++){
			for (var m=0;m<formElementPrefix.length;m++){
				var elementName=formElementPrefix[m]+(n+1);
				var temp=checkedForm[elementName].value;
				if(temp==""){
					alert('请填写排名第'+(n+1)+"的4S店的"+titleInfo[m]+"信息！");
					flag=false;
					checkedForm[elementName].focus();
					break;
				}
			}
			if(!flag)
				break;
		}
		if(flag)
			return checkTotalInfo();
		return flag;		
	}
		//changeShopInputState();
		</script>
	</body>
</html>
